(function(angular) {
	'use strict';
	angular.module("fs.waf").factory("companyImgService", companyImgService);
	companyImgService.$inject = [ '$q', 'loggerFactory', 'commonService',
			'ajaxServiceFactory', 'modalService' ];
	function companyImgService($q, loggerFactory, commonService,
			ajaxServiceFactory, modalService) {
		var log = loggerFactory.getLogger("companyImgService"), ajaxService = ajaxServiceFactory.buildAjaxService({
			getImgCatOptions : {
				url : 'do/cda/dataList/companyImgCat',
				method : 'post'
			},
			getGlobalImgCatOptions : {
				url : 'do/cda/dataList/gCompanyImgCat',
				method : 'post'
			}
		});

		function initGlobalImgCat(ctrl) {
			var defer = $q.defer();
			ajaxService.getGlobalImgCatOptions().then(function(response) {
				ctrl.gImgCatOptions = response;
				ctrl.gImgCatOptions.hasEmptyOption = true;
				defer.resolve(response);
			}, angular.noop);
			return defer.promise;
		}

		function initOptions(ctrl) {
			var defer = $q.defer();
			ajaxService.getImgCatOptions().then(function(response) {
				ctrl.imgCatOptions = response;
				ctrl.imgCatOptions.hasEmptyOption = true;
				defer.resolve(response);
			}, angular.noop);

			return defer.promise;
		}
		return {
			initOptions : initOptions,
			initGlobalImgCat : initGlobalImgCat
		};
	}
})(angular);
